import tool from '../modules/tool'
import config from '../config'

export default {
  format(apiName, data) {
    // if(apiName=='/setting/banner'){
    //   for(let i=0;i<data.length;i++){
    //     data[i].fileName = config.imagePrefix + data[i].fileName
    //   }
    // }
    
    return data
  },
  formatBeforeSend(apiName, data) {
    data = tool.dcJSON(data)
    if (apiName == '/product/updateInfo' || apiName == '/activity/updateInfo') {
      if (typeof (data.item.imageUrl) == 'object') data.item.imageUrl = JSON.stringify(data.item.imageUrl)
      if (typeof (data.item.options) == 'object') data.item.options = JSON.stringify(data.item.options)
      if (data.item.createdAt) data.item.createdAt = (data.item.createdAt).toString()
      if (data.item.updatedAt) data.item.updatedAt = (data.item.updatedAt).toString()
    }
    return data
  }
}